import 'package:dailoz/size_config.dart';
import 'package:flutter/material.dart';

class InputField extends StatelessWidget {
  const InputField({
    Key? key,
    this.onChanged,
    this.keyboardType = TextInputType.text,
    required this.borderColor,
    required this.borderWidth,
    this.hintText,
    this.prefixIcon,
    this.prefixIconColor,
    this.prefixIconSize,
    this.hintTextColor,
    this.suffixIcon,
    this.suffixIconColor,
    this.suffixIconSize,
    required this.hintTextSize,
    this.textInvisible = false,
    required this.controller,
    this.focusNode,
    this.suffixOnPress,
    this.onSubmitted,
  }) : super(key: key);

  final ValueChanged<String>? onChanged;
  final ValueChanged<String>? onSubmitted;
  final TextInputType? keyboardType;
  final Color? borderColor;
  final double? borderWidth;
  final String? hintText;
  final IconData? prefixIcon;
  final Color? prefixIconColor;
  final double? prefixIconSize;
  final Color? hintTextColor;
  final IconData? suffixIcon;
  final Color? suffixIconColor;
  final double? suffixIconSize;
  final double? hintTextSize;
  final bool? textInvisible;
  final TextEditingController? controller;
  final FocusNode? focusNode;
  final VoidCallback? suffixOnPress;

  @override
  Widget build(BuildContext context) {
    return TextField(
      focusNode: focusNode,
      controller: controller,
      obscureText: textInvisible!,
      onChanged: onChanged,
      onSubmitted: onSubmitted,
      keyboardType: keyboardType,
      decoration: InputDecoration(
        enabledBorder: UnderlineInputBorder(
          borderSide: BorderSide(color: borderColor!, width: borderWidth!),
        ),
        hintText: hintText,
        prefixIcon: Icon(
          prefixIcon,
          color: prefixIconColor,
          size: prefixIconSize,
        ),
        suffixIcon: IconButton(
          onPressed: suffixOnPress,
          icon: Icon(
            suffixIcon,
            color: suffixIconColor,
            size: suffixIconSize,
          ),
        ),
        hintStyle: TextStyle(
          color: hintTextColor,
          fontSize: SizeConfig.getProportionateFontSize(hintTextSize!),
        ),
      ),
    );
  }
}
